<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册界面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }

        .admin-id {
            color: #9abcda;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form-item layui-form">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <h1>用户添加</h1>
            </div>
        </div>
        <hr>

<!--        <from class="layui-form">-->
            <div class="layui-form layuimini-form">
                <div class="layui-form-item">
                    <label class="layui-form-label required">学工号/教工号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="number" lay-verify="required" lay-reqtext="学工号/教工号"
                               placeholder="学工号/教工号"
                               value=""
                               class="layui-input" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">用户密码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="password" lay-verify="required" lay-reqtext="用户密码不能为空"
                               placeholder="请输入用户密码"
                               value=""
                               class="layui-input" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required" lay-reqtext="真实姓名不能为空"
                               placeholder="请输入真实姓名"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">身份</label>
                    <div class="layui-input-inline">
                        <input type="text" name="identity" lay-verify="required" lay-reqtext="身份不能为空"
                               placeholder="请输入身份"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">专业</label>
                    <div class="layui-input-block">
                        <input type="text" name="major" lay-verify="required" lay-reqtext="专业不能为空" placeholder="请输入专业"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">班级</label>
                    <div class="layui-input-block">
                        <input type="text" name="unit" lay-verify="required" lay-reqtext="班级不能为空"
                               placeholder="请输入班级（学生所属班级/教室管理班级）" value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">性别</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="gender" value="男" title="男" checked="">
                        <input type="radio" name="gender" value="女" title="女">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">年龄</label>
                    <div class="layui-input-inline">
                        <input type="text" name="age" lay-verify="required" lay-reqtext="年龄不能为空" placeholder="请输入年龄"
                               value=""
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label required">身份证号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id_number" lay-verify="required" lay-reqtext="身份证号不能为空！"
                               placeholder="请输入身份证号"
                               value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <a href="admin_add.html" class="admin-id">添加管理员</a>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认添加</button>
                    </div>
                </div>
            </div>
<!--        </from>-->

    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        form.on('submit(saveBtn)', function (obj) {
            obj = obj.field;
            obj = {
                "number": obj.number,
                "password": obj.password,
                "name": obj.name,
                "identity": obj.identity,
                "major": obj.major,
                "unit": obj.unit,
                "gender": obj.gender,
                "age": parseInt(obj.age),
                "id_number": obj.id_number
            };
            console.log("看看对象");
            console.log(obj);
            console.log("看看JSON.stringify(obj)");
            console.log(JSON.stringify(obj));
            $.ajax({
                type: "POST",
                contentType: 'application/json',
                url: "http://110.42.199.36:8081/user/registerUser",
                data: JSON.stringify(obj),
                dataType: 'json',
                success: function (data) {
                    console.log("成功");
                    console.log(data);
                    layer.alert('添加成功');
                }
            });
            return false;
        });


    });
</script>
</body>
</html>